//
//  LotteryEntry.m
//  lottery
//
//  Created by KaiKai on 11-6-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "LotteryEntry.h"


@implementation LotteryEntry

- (id)init
{
//	return [self initWithEntryDate:[NSCalendarDate calendarDate]];
	[self dealloc];
	@throw [NSException exceptionWithName:@"KaiKaiTestException" reason:@"init LotteryEntry must have param" userInfo:nil];
	
	return nil;
}

- (id)initWithEntryDate:(NSCalendarDate *)theDate
{
	if (![super init])
		return nil;
	
	entryDate = [theDate retain];
	firstNumber = (int)random() % 100 + 1;
	secondNumber = (int)random() % 100 + 1;
	return self;
}

- (void)setEntryDate:(NSCalendarDate *)date
{
	[date retain];
	[entryDate release];
	entryDate = date;
}

- (NSCalendarDate *)entryDate
{
	return entryDate;
}

- (int)firstNumber
{
	return firstNumber;
}

- (int)secondNumber
{
	return secondNumber;
}

- (NSString *)description
{
	NSString *result = [[NSString alloc] initWithFormat:@"%@ = %3d and %3d",
						[entryDate descriptionWithCalendarFormat:@"%Y-%m-%d"],
						firstNumber, secondNumber];
	
	[result autorelease];
//	[result release];
	return result;
}

- (void)dealloc
{
	NSLog(@"Deallocing %@", self);
	[entryDate release];
	[super dealloc];
}

@end
